from django.conf.urls import url
from django.contrib import admin
from . import views, views_serializer, views_apiview, views_genericapivew, views_modelmixin, views_modelmixinchild, \
    views_viewset, views_modelviewset

from rest_framework.routers import SimpleRouter, DefaultRouter

urlpatterns = [
    # url(r'^$', views.IndexView.as_view()),
    # url(r'^books/$', views.BooksView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', views.BookView.as_view()),
    #
    # url(r'^books/$', views_serializer.BooksView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', views_serializer.BookView.as_view()),
    #
    # url(r'^heros/$', views.HerosView.as_view()),
    # url(r'^heros/(?P<pk>\d+)/$', views_serializer.HeroView.as_view()),

    # url(r'^books/$', views_apiview.BooksView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', views_apiview.BookView.as_view()),

    # url(r'^books/$', views_genericapivew.BooksView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', views_genericapivew.BookView.as_view()),
    # url(r'^books/$', views_modelmixin.BooksView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', views_modelmixin.BookView.as_view()),

    # url(r'^books/$', views_modelmixinchild.BooksView.as_view()),
    # url(r'^books/(?P<pk>\d+)/$', views_modelmixinchild.BookView.as_view()),

    # url(r'^books/$', views_viewset.BooksView.as_view({'get':'list','post':'create'})),
    # url(r'^books/(?P<pk>\d+)/$', views_viewset.BooksView.as_view({'get':'retrieve','put':'update','delete':'destory'})),

    # url(r'^books/$', views_modelviewset.BooksView.as_view({'get': 'list', 'post': 'create'})),
    # url(r'^books/(?P<pk>\d+)/$',
    #     views_modelviewset.BooksView.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy'})),
    # url(r'^books/last_book/$',
    #     views_modelviewset.BooksView.as_view({'get': 'last_book'})),
    #
    # url(r'^books/(?P<pk>\d+)/bread_book/$',
    #     views_modelviewset.BooksView.as_view({'get': 'bread_book'})),


]
# 路由类初始化
router = SimpleRouter()
# 路由的注册生成
router.register('books', views_modelviewset.BooksView, base_name='books')
# 获取生成后的路由
print(router.urls)

urlpatterns += router.urls
